//Starting the Server and Client Download Files
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

//Spawning and Determining Team

function GM:Initialize( )
	self.BaseClass:Initialize( )
	GAMEMODE:SetupTeams()
end


function GM:PlayerInitialSpawn( ply )
     ply:ConCommand( "team_menu" )
     ply:ConCommand( "bind F1 gm_showhelp" )
     ply:ConCommand( "gm_showhelp" )
end

function GM:PlayerSpawn( ply ) 

	GAMEMODE:SetupPlayer( ply )
	
end

//Giving specif team members their respective weapons

function GM:SetupPlayer( ply )
    if ply:Team() == 1 then 
        ply:Give("weapon_smg1")
        ply:GiveAmmo(100, "smg1")
        ply:SetModel( "models/player/combine_soldier.mdl" )
        ply:SetMaxHealth(150)
        ply:SetHealth(150)
    elseif ply:Team() == 3 then 
        ply:Give("weapon_crowbar")
        ply:Give("weapon_pistol")
        ply:GiveAmmo(100, "pistol")
        ply:SetModel( "models/player/gman_high.mdl" )
        ply:SetMaxHealth(500)
        ply:SetHealth(500)
    elseif ply:Team() == 2 then
		ply:Give("weapon_smg1")
		ply:Give("weapon_pistol")
		ply:GiveAmmo(55, "pistol")
		ply:GiveAmmo(100, "smg1")
		ply:SetModel( "models/player/group01/male_05.mdl" )
		ply:SetMaxHealth(200)
		ply:SetHealth(200)
	else
		ply:Give("weapon_crowbar")
		ply:SetMaxHealth(120)
		ply:SetHealth(120)	
		ply:SetModel( "models/player/group01/male_05.mdl" )		    
    end
end

//Change Teams by ConCommand

function team_1( ply )
	if team.NumPlayers( 1 ) >8 then
    ply:SetTeam( 1 )
    end
end
 
function team_2( ply )
    if team.NumPlayers( 2 ) >6 then
    ply:SetTeam( 2 )
    end
end

function team_3( ply )
	if team.NumPlayers( 3 ) >1 then
    ply:SetTeam( 3 )
    end
end
 
concommand.Add( "team_1", team_1 )
concommand.Add( "team_2", team_2 )
concommand.Add( "team_3", team_3 )


